varying vec4 modelCoord;;
varying vec4 lp;
varying vec4 eyeCoord;

const vec3 ref = vec3(-1.3, 0.0, -0.5);
const float r = 0.5;

void main()
{
  vec3 n = modelCoord.xyz;

	gl_FragColor = vec4(0.6, 0.6, 0.6, 1.0);
  
  vec3 vc = ref - modelCoord.xyz;
	if(length(vc) < r)
    n = vc;

	n = normalize(gl_NormalMatrix * n);

  float diff = max(0.0, dot(normalize( gl_LightSource[0].position - eyeCoord).xyz, n));

  gl_FragColor.rgb *= diff + 0.2;
}
